import { request } from "./request";
export function getAllNewsList(collections){
    let p = new Promise((resolve)=>{
        let  news = {
            __all__: { list: [] },
            news_hot: { list: [] },
            news_society: { list: [] },
            news_entertainment: { list: [] },
            news_tech: { list: [] },
            news_military: { list: [] },
            news_sports: { list: [] },
            news_car: { list: [] },
            news_finance: { list: [] },
            news_world: { list: [] },
            news_fashion: { list: [] },
            news_travel: { list: [] },
            news_discovery: { list: [] },
            news_baby: { list: [] },
            news_regimen: { list: [] },
            news_story: { list: [] },
            news_essay: { list: [] },
            news_game: { list: [] },
            news_history: { list: [] },
            news_food: { list: [] },
          }
        
           for(let key in news){
            request({
                url: 'list/',
                params: {
                  ac: "wap",
                  format: "json_raw",
                  tag:key,
                  as: "A175ADC1C1BAE7E",
                  cp: "5D118A3E877E8E1",
                  _signature: "f60bLAAAIr6R60RntmQLRn-tGz"
                },
              }).then((res) => {
              news[""+key+""].list.push(...res.data);
              console.log(news[""+key+""])
            });
          }
          resolve(news)
    })
    p.then((data)=>{
        let collect = {
            list:[]
        }
        collections.forEach(val=>{
            console.log(val)
            for(let key in data){
              data[""+key+""].list.forEach(v=>{
                  console.log(v.item_id)
                if(v.item_id == val){
                  collect.list.push(v)
                  console.log(collect)
                }
              })
            }
        })
    })
}